import os
import sys

from openai import OpenAI
sys.path.append('/JiuTian/swarm/swarm-main/swarm')
from swarm import Swarm,Agent

#测试基本功能

client = OpenAI(api_key=os.environ["OPENAI_API_KEY_JIUTIAN"], base_url=os.environ["OPENAI_BASE_URL_JIUTIAN"])

def get_date():
    '''
    返回今天的日期
    :return:
    '''
    return '今天是星期二'

#测试多智能体功能
swarm_client = Swarm(client)
agent = Agent(name = "日期Agent",instructions= "你是一个乐于助人的助手",functions=[get_date])

response = swarm_client.run(agent=agent,messages=[{"role":"user","content":"今天是星期几？"}])
print(response.messages[-1]["content"])